using OracleInternal.Common;

namespace OracleInternal.TTC
{
	internal class TTCSessionReturnValues : TTCFunction
	{
		private long m_s2cSessionGetflags;

		private long m_newSesionId;

		private long m_newSerialNumber;

		private TTCKeywordValuePair[] m_sessProperties;

		internal TTCSessionReturnValues(MarshallingEngine mEngine)
			: base(mEngine, 4, 0)
		{
		}

		internal void Receive()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCSessionReturnValues, OracleTraceFuncName.Receive);
			}
			try
			{
				m_marshallingEngine.UnmarshalUB2(bIgnoreData: true);
				m_marshallingEngine.UnmarshalUB1(bIgnoreData: true);
				int num = m_marshallingEngine.UnmarshalUB2();
				if (num > 0)
				{
					m_marshallingEngine.UnmarshalUB1(bIgnoreData: true);
					m_sessProperties = new TTCKeywordValuePair[num];
					for (int i = 0; i < num; i++)
					{
						m_sessProperties[i] = TTCKeywordValuePair.Unmarshal(m_marshallingEngine);
					}
				}
				m_marshallingEngine.m_connImplReference.UpdateSessionAttributes(m_sessProperties, null);
				m_s2cSessionGetflags = m_marshallingEngine.UnmarshalUB4();
				m_newSesionId = m_marshallingEngine.UnmarshalUB4();
				m_newSerialNumber = m_marshallingEngine.UnmarshalUB2();
				bool flag = (m_s2cSessionGetflags & 4) == 4;
				if (flag)
				{
					m_marshallingEngine.m_connImplReference.SessionId = (int)m_newSesionId;
					m_marshallingEngine.m_connImplReference.SerialNumber = (int)m_newSerialNumber;
					m_marshallingEngine.m_connImplReference.NewDRCPSessionAttached();
				}
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					string text = string.Format("(SESSGET_SESSION_CHANGED={0}) (SessionId={1}) (SerialNumber={2}) (purge_stmt_cache={0})", flag, m_newSesionId, m_newSerialNumber);
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCSessionReturnValues, OracleTraceFuncName.Receive, text);
				}
				m_marshallingEngine.m_bDRCPSessionAttached = true;
				m_marshallingEngine.m_connImplReference.bDRCPServerProcessAttached = true;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCSessionReturnValues, OracleTraceFuncName.Receive);
				}
			}
		}
	}
}
